﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using TimKen.DataEntity;

namespace TimKen.BussLogic
{
 /// <summary>
	/// 加入我们管理类
	/// </summary>
    public class JobManager
    {
        private readonly DataAccess.JobDAO dal = new TimKen.DataAccess.JobDAO();
        public JobManager()
        { }
        #region  成员方法

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int JobID)
        {
            return dal.Exists(JobID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Job model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Job model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int JobID)
        {

            dal.Delete(JobID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Job GetModel(int JobID)
        {

            return dal.GetModel(JobID);
        }
 

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Job> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<Job> modelList = new List<Job>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                Job model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Job();
                    if (ds.Tables[0].Rows[0]["JobID"].ToString() != "")
                    {
                        model.JobID = int.Parse(ds.Tables[0].Rows[0]["JobID"].ToString());
                    }
                    model.JobNo = ds.Tables[0].Rows[0]["JobNo"].ToString();
                    model.JobName = ds.Tables[0].Rows[0]["JobName"].ToString();
                    if (ds.Tables[0].Rows[0]["ValidFrom"].ToString() != "")
                    {
                        model.ValidFrom = DateTime.Parse(ds.Tables[0].Rows[0]["ValidFrom"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["ValidTo"].ToString() != "")
                    {
                        model.ValidTo = DateTime.Parse(ds.Tables[0].Rows[0]["ValidTo"].ToString());
                    }
                    model.JobDesc = ds.Tables[0].Rows[0]["JobDesc"].ToString();
                    model.Qualifications = ds.Tables[0].Rows[0]["Qualifications"].ToString();
                    if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["LanguageID"].ToString() != "")
                    {
                        model.LanguageID = int.Parse(ds.Tables[0].Rows[0]["LanguageID"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(int PageSize, int PageIndex,int LanguageID)
        {
            return dal.GetList(PageSize, PageIndex,LanguageID);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere)
        {
            return dal.GetList(PageSize, PageIndex, strWhere);
        }



        #endregion  成员方法
    }
}
